<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
	  <home></home>
  </div>
  <template id="Home">
	  <div>
		  Home组件
		  <common-head 
			:title=" '我是字符串' "
			:propsb=" 123 "
			:propsc="888"
			propd="传值了"
		></common-head>
	  </div>
  </template>
  
  <script src="./vue.js"></script>
  <script>
	  // 头部组件
	  /*
	  props
		类型验证 （props数据类型）
		必传验证 
		默认值
	  */
	 const CommonHead = {
		props: {
			title: String,
			propsb: [Number,String],
			propsc:{
				type: Number,
				required: true
			},
			propd: {
				type: String,
				default: '我是一个默认值'
			},
			arr:{
				type: Array,
				default: ()=> [1,2,3,4]
			}
		},
		template:`
			<div>
				<button @click="changeTitle">点击改变props的值</button>
				我是头部组件
				<h2> {{title}} </h2>
				{{ propsb }}
				--
				{{ propsc }}
				{{ propd }}
				<ul>
					<li v-for="item in arr" :key="item">
						{{ item }}
					</li>
				</ul>
			</div>
		`,
		data () {
			return {
				msg: 'hello'
			}
		},
		methods:{
			changeTitle(){
				this.title="啊啊啊啊啊"
			}
		}
	 }
    const Home = {
      template: '#Home',
	  components: {
		  CommonHead
	  },
	  data () {
		  return {
			  msg: '我是home组件中data中的数据'
		  }
	  }
    }
	
	Vue.component('Home',Home)
	
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>